package com.thingple.rodbell.packet;

import java.util.concurrent.LinkedBlockingQueue;

public class PacketBuffer extends LinkedBlockingQueue<Byte> {

    public PacketBuffer(int capacity) {
        super(capacity);
    }

    public byte get() {
        Byte b = poll();
        if (b == null) {
            b = 0x00;
        }
        return b;
    }

    public byte[] get(int size) {
        byte[] buf = new byte[size];
        for (int i=0; i < size; i++) {
            buf[i] = get();
        }
        return buf;
    }
}
